package com.hhh.petadopt.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hhh.petadopt.pojo.News;
import com.hhh.petadopt.service.NewsService;

/**
 * 新闻咨询展示
 * @author 杜镇声声
 *
 */
@Controller
public class NewsController {
	
	@Autowired
	private NewsService newsService;
	
	//展示新闻咨询页面
	@RequestMapping(value="/news/newList")
	public String showNewsList(Model model) {
		//执行查询
		List<News> newsListt = newsService.selectNews();
		//将数据保存到模型中
		model.addAttribute("newsListt", newsListt);
		return "newsList";
	}
	//显示新闻详情
	@RequestMapping(value="/news/NewsInfo")
	public String NewsInfo(Integer id,Model model) {
		//执行查询
		News newsInfo = newsService.selectNewsInfo(id);
		//数据存放到模型中
		model.addAttribute("newsInfo", newsInfo);
		//返回视图
		return "newsInfo";
	}

}
